﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace guest_management_in_a_hotel
{
    public partial class FrmQuanLyKhachHang : Form
    {
        SqlConnection conn;
        SqlCommand cmd;
        SqlDataAdapter da;
        DataSet ds;
        public static string CMND;
        public FrmQuanLyKhachHang()
        {
            InitializeComponent();
        }

        private void FrmQuanLyPhong_Load(object sender, EventArgs e)
        {
            
        }



        private void FrmQuanLyKhachHang_Load(object sender, EventArgs e)
        {
            conn = Connect.getConnection();
            conn.Open();
            String strSql = "select Guest_Name[Họ và tên],Guest_Sex[Giới tính],Guest_DOB[Ngày sinh],Guest_Address[Địa chỉ],Guest_Passport_No[Số CMND],Guest_Nationality[Quốc tịch] from TblGuests order by Guest_Name asc";
            cmd = new SqlCommand(strSql, conn);
            da = new SqlDataAdapter(cmd);
            ds = new DataSet();
            da.Fill(ds, "phong");
            dgvQLKhach.DataSource = ds.Tables[0];
            conn.Close();
            btnDK.Enabled = false;
        }

        private void btndkcancel_Click_1(object sender, EventArgs e)
        {
            FrmMain frmMain = new FrmMain();
            frmMain.Show();
            this.Hide();
        }

        private void btnAll_Click(object sender, EventArgs e)
        {
            conn = Connect.getConnection();
            conn.Open();
            String strSql = "select Guest_Name[Họ và tên],Guest_Sex[Giới tính],Guest_DOB[Ngày sinh],Guest_Address[Địa chỉ],Guest_Passport_No[Số CMND],Guest_Nationality[Quốc tịch] from TblGuests order by Guest_Name asc";
            cmd = new SqlCommand(strSql, conn);
            da = new SqlDataAdapter(cmd);
            ds = new DataSet();
            da.Fill(ds, "phong");
            dgvQLKhach.DataSource = ds.Tables[0];
            conn.Close();
            btnDK.Enabled = false;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            conn = Connect.getConnection();
            conn.Open();

            String strSql = "select TblGuests.Guest_Name[Họ và tên],TblGuests.Guest_Sex[Giới tính],TblGuests.Guest_DOB[Ngày sinh],TblGuests.Guest_Address[Địa chỉ],TblGuests.Guest_Passport_No[Số CMND],TblGuests.Guest_Nationality[Quốc tịch],TblReserve.Room_Number[Phòng đang thuê] from TblGuests,TblReserve where TblReserve.Guest_Passport_No=TblGuests.Guest_Passport_No";
            cmd = new SqlCommand(strSql, conn);
            da = new SqlDataAdapter(cmd);
            ds = new DataSet();
            da.Fill(ds, "phong");
            dgvQLKhach.DataSource = ds.Tables[0];
            conn.Close();
            btnDK.Enabled = true;
        }

        private void btnDK_Click(object sender, EventArgs e)
        {
          //  string hoten= dgvQLKhach.CurrentRow.Cells[0].Value.ToString();
          //  string gioitinh =dgvQLKhach.CurrentRow.Cells[1].Value.ToString();
          //  string ngaysinh= dgvQLKhach.CurrentRow.Cells[2].Value.ToString();
         //   string diachi= dgvQLKhach.CurrentRow.Cells[3].Value.ToString();
             CMND = dgvQLKhach.CurrentRow.Cells[4].Value.ToString();
        //    string quoctich= dgvQLKhach.CurrentRow.Cells[5].Value.ToString();
           // MessageBox.Show(CMND);
            FrmThongTinPhong frmThongtin = new FrmThongTinPhong();
            frmThongtin.Show();
            this.Hide();
        }


    }
}
